<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('渠道统计列表')" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-select-css" />
    <th:block th:include="include :: daterangepicker-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
<!--            <div class="col-sm-12 search-collapse">-->
<!--                <form id="formId">-->
<!--                    <div class="select-list">-->
<!--                        <ul>-->
<!--                            <li>-->
<!--                                <label>日期：</label>-->
<!--                                <input type="text" name="dateInfo" id="dateInfo" autocomplete="off"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>-->
<!--                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>-->
<!--                            </li>-->
<!--                        </ul>-->
<!--                    </div>-->
<!--                </form>-->
<!--            </div>-->

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table" class=" table-hover"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
     <th:block th:include="include :: daterangepicker-js" />
     <th:block th:include="include :: bootstrap-select-js" />
    <script th:inline="javascript">

        var editFlag = [[${@permission.hasPermi('extend:count:edit')}]];
        var removeFlag = [[${@permission.hasPermi('extend:count:remove')}]];
        var prefix = ctx + "extend/count";
        var prefixView = ctx + "extend/countview/";

        $(function() {
            var options = {
                id:"bootstrap-table",
                url: prefix + "/zclist",
                modalName: "渠道统计",
                striped: false,
                // rowStyle: function (row, index) {
                //     return {classes:'table_row'}
                // },
                columns: [
                //     {
                //     checkbox: true
                // },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'dateInfo',
                    title: '日期'
                },
                {
                    field: 'channelName',
                    title: '渠道名称',
                    formatter: function (value,row,index){

                        var result = '';
                        if (row.channelName == undefined){
                            result = '-';
                        }else{
                            if (row.channelType == 'DC'){
                                result = '<span style="color: #1c84c6; border-bottom: 1px solid " onclick="channelInfoView(\''+row.id+'\',\'' +row.channelName+'-'+row.dateInfo+'\')">'+row.channelName+'</a>';
                            }else if (row.channelType == 'ZD'){
                                result = '<span style="color: #c90e46; border-bottom: 1px solid " onclick="channelInfoView(\''+row.id+'\',\'' +row.channelName+'-'+row.dateInfo+'\')">'+row.channelName+'</a>';
                            }else{
                                result = '<span style=" border-bottom: 1px solid " onclick="channelInfoView(\''+row.id+'\',\'' +row.channelName+'-'+row.dateInfo+'\')">'+row.channelName+'</a>';
                            }
                        }
                        return result;
                    }
                },
                {
                    field: 'uvCount',
                    title: 'uv数量',
                    formatter: function (value,row,index){
                        var result = (row.channelCode == undefined)?row.uvCount:'<span style="color: #1c84c6; border-bottom: 1px solid" onclick="uvCountView(\''+row.id+'\',\'' +row.channelName+'-'+row.dateInfo+'\')">'+row.uvCount+'</a>';
                        return result;
                    }
                },
                {
                    field: 'uvCost',
                    title: 'uv成本'
                },
                {
                    field: 'registerCount',
                    title: '注册数量',
                    formatter: function (value, row, index){
                        return row.realUserNumber == undefined?row.registerCount:row.registerCount+' ('+ row.realUserNumber +')'
                    }
                },
                {
                    field: 'registerRate',
                    title: '注册率',
                    formatter: function (value, row, index){
                        return row.realUserNumber == undefined?'<span style="color: red">'+row.registerRate+'</span>':'<span style="color: red">'+row.registerRate+ '('+ row.registerRateReal+')'+'</span>';
                    }
                },
                {
                    field: 'loginCount',
                    title: '登陆数量'
                },
                {
                    field: 'requestWechatCount',
                    title: '微信来源数'
                },
                {
                    field: 'authCount',
                    title: '认证数量'
                },
                {
                    field: 'authRate',
                    title: '认证率',
                    formatter: function (value, row, index){
                        return '<span style="color: red">'+row.authRate+'</span>'
                    }
                },
                {
                    field: 'downloadCount',
                    title: '下载数量'
                },
                {
                    field: 'downloadRate',
                    title: '下载率',
                    formatter: function (value, row, index){
                        return '<span style="color: red">'+row.downloadRate+'</span>'
                    }
                },
                {
                    field: 'uvProdList',
                    title: 'uv列表'
                },
                ]
            };
            $.table.init(options);


            window.uvCountView = function (id, title){
                var url = prefixView + "uvCountView/" + id;
                $.modal.open(title, url);
            }

        });

        $('#dateInfo').daterangepicker({
                "timePicker": false,
                "timePicker24Hour": false,
                "timePickerSeconds": false,
                "locale": {
                    "direction": "ltr",
                    "format": "YYYY-MM-DD",
                    "separator": " ~ ",
                    "applyLabel": "确定",
                    "cancelLabel": "取消",
                    "daysOfWeek": [ "七", "一", "二", "三", "四", "五", "六"],
                    "monthNames": ["1","2","3","4","5","6","7","8","9","10","11","12"
                    ],
                    // "firstDay": 1
                }
            },function (){}
        );

        function channelInfoView(id, title){
            var url = prefixView + "channelInfoView/" + id;
            $.modal.open(title, url);
        }

        function proUvCountView(id, title){
            var url = prefixView + "proUvCountView/" + id;
            $.modal.open(title, url);
        }

    </script>
</body>
</html>